﻿/*
 * Created by SharpDevelop.
 * User: Jose
 * Date: 23/07/2011
 * Time: 1:58 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Web;

namespace SoftwareMonkeys.Scriptech.Scripts
{
	/// <summary>
	/// Description of ScriptPath.
	/// </summary>
	public class ScriptPath
	{
		
		static public string GetUrl(string scriptName)
		{
			return GetUrl(scriptName, String.Empty);
		}
		
		static public string GetUrl(string scriptName, string queryStrings)
		{
			if (queryStrings.IndexOf("?") > -1)
				queryStrings = queryStrings.Replace("?", "&");
			
			if (queryStrings.Length > 0 && queryStrings.Substring(0, 1) != "&")
				queryStrings = "&" + queryStrings;
			
			string path = Scripts.MapUrl(scriptName, queryStrings);
			
			return path;
		}
		
		static public string GetUrl(string scriptName, params string[] queryStringsToUse)
		{
			string queryStrings = String.Empty;
			
			foreach (string q in queryStringsToUse)
			{
				queryStrings = queryStrings + "&" + q + "=" + HttpContext.Current.Request.QueryString[q];
			}
			
			return GetUrl(scriptName, queryStrings);
		}
		
		static public string GetUrl(string scriptName, string queryStrings, params string[] queryStringsToUse)
		{			
			foreach (string q in queryStringsToUse)
			{
				queryStrings = queryStrings + "&" + q + "=" + HttpContext.Current.Request.QueryString[q];
			}
			
			return GetUrl(scriptName, queryStrings);
		}
	}
}
